package com.cims.action.task;

import java.util.ArrayList;
import java.util.List;

import com.cims.action.BaseAction;
import com.cims.bo.task.TaskBO;
import com.cims.bo.task.TaskBOImpl;
import com.cims.common.vo.Item;
import com.cims.common.vo.Task;


public class TaskAction  extends BaseAction{
	private TaskBO bo = new TaskBOImpl();
	private List<Task> listTask = new ArrayList<Task>();
	private int staffId = 1;
	private Boolean getToday = false;

	public Boolean getGetToday() {
		return getToday;
	}

	public void setGetToday(Boolean getToday) {
		this.getToday = getToday;
	}

	public int getStaffId() {
		return staffId;
	}

	public void setStaffId(int staffId) {
		this.staffId = staffId;
	}

	// list all order
	public String list() {
		try {
			staffId = (int) session.get("staffUserId");
			if(getToday) {
				listTask = bo.getTodayListTaskByStaffId(staffId);
			}
			else {
				listTask = bo.getListTaskByStaffId(staffId);
			}

		} catch (Exception e) {
			// TODO: handle exception
		}
		return SUCCESS;
	}

	public List<Task> getListTask() {
		return listTask;
	}

	public void setListTask(List<Task> listTask) {
		this.listTask = listTask;
	}

	public void test() {
		System.out.println("blah blah");
	}

	public String getItemType(Item item) {
		if(item.getProduct() != null) return "P";
		if(item.getService() != null) return "S";
		if(item.getGraves() != null) return "G";
		if(item.getLands() != null) return "L";
		
		return "Cannot detect";
	}
}
